<template>
  <div class="chat">
    <tabs class="tabs-screen" :value="value" @getIndex="getCurrentIndex">
      <tab id="tab-screen" v-for="(element,index) in chatlist" :label="element.chatType" :index="index + 1 " :key="index">
        <ChatList :childData="element.chatList" />
      </tab>
      <div @click="screenBtn" class="chat-screen">
        <i class="icon iconfont">&#xe64a;</i>
      </div>
      <div v-if="flag" class="screen-list">
        <ul>
          <li @click="screenActive(index)" :class="{ 'active' : active == index }" v-for="(item,index) in screenList " :key="index">{{ item.title }}</li>
        </ul>
      </div>
    </tabs>
  </div>
</template>
<script>
import CommonHeader from "@/components/CommonHeader"
import ChatList from "./ChatList"

export default {
  name: 'ChatView',
  data() {
    return {
      bannersData: [],
      value: 1,
      flag: 0, //隐藏,
      active: '',
      screenList: [{
          price: 0,
          title: "有声读物"
        },
        {
          price: 1,
          title: "评论最多"

        },
        {
          price: 2,
          title: "收藏排名"

        },
        {
          price: 3,
          title: "点赞排名",
        },
        {
          price: 4,
          title: "人气排行",
        },
        {
          price: 5,
          title: "热门推荐"
        }
      ]
    }
  },
  methods: {
    getCurrentIndex(index) {
      this.value = index

    },
    screenBtn(event) {
      this.flag = !this.flag;
    },
    screenActive(index) {
      this.active = index;
    }
  },
  components: {
    CommonHeader,
    ChatList
  },
  props: {
    chatlist: {
      type: Array,
      default: function() {
        return []
      }
    }
  }
}

</script>
<style lang="css" scoped>
.chat {  
  width: 100%;
  font-size: 0.16rem;
  margin-right: 0;
  position: relative;
  /*display: flex;*/
}
#tab-screen{
  display: flex;
  text-align: center;
  width: 85%;
}

.tabs-screen {
 background: #fff;
  border-top: 1px solid #E0E0E0;
  flex: 0.8;
 
}

.chat-screen {
  position: absolute;
  border-left: 1px solid #E0E0E0;
  width: 0.55rem;
  height: 0.54rem;
  right: 0;
  top: 0rem;
  text-align: center;
  border-bottom: 1px solid #E0E0E0;
  border-top: 1px solid #E0E0E0;
  background-color: #fff;
}

.chat-screen i {
  font-size: 0.22rem;
  text-align: center;
  line-height: 0.53rem;
  color: #0F9F59;
}
.screen-list {
  width: 1.1rem;
  height: 2.5rem;
  background: #fff;
  position: absolute;
  z-index: 999;
  right: 0;
  top: 0.56rem;
  box-shadow: 0 0 1px;
}

.screen-list ul {
  line-height: 0.4rem;
  text-align: center;
}

.screen-list .active {
  background: skyblue;
}

</style>
